home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / g / gnu_c / gempp19.zoo / gem++19 / src / gemcha.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-06  |  1.1 KB  |  62 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  This file is Copyright 1993 by Warwick W. Allison.
  4. //  This file is part of the gem++ library.
  5. //  You are free to copy and modify these sources, provided you acknowledge
  6. //  the origin by retaining this notice, and adhere to the conditions
  7. //  described in the file COPYING.LIB.
  8. //
  9. /////////////////////////////////////////////////////////////////////////////
  10. #include "gemcha.h"
  11.  
  12. GEMchangearea::GEMchangearea() :
  13.     GRect(0,0,0,0)
  14. {
  15. }
  16.  
  17. void GEMchangearea::Clear()
  18. {
  19.     g_x=0;
  20.     g_y=0;
  21.     g_w=0;
  22.     g_h=0;
  23. }
  24.  
  25. bool GEMchangearea::Changed() const
  26. {
  27.     return !!g_w;
  28. }
  29.  
  30. void GEMchangearea::Include(int x, int y)
  31. {
  32.     if (Changed()) {
  33.         if (x<g_x) {
  34.             g_w+=g_x-x;
  35.             g_x=x;
  36.         }
  37.         if (y<g_y) {
  38.             g_h+=g_y-y;
  39.             g_y=y;
  40.         }
  41.         if (g_x+g_w-1<x) {
  42.             g_w=x-g_x+1;
  43.         }
  44.         if (g_y+g_h-1<y) {
  45.             g_h=y-g_y+1;
  46.         }
  47.     } else {
  48.         g_x=x;
  49.         g_y=y;
  50.         g_w=1;
  51.         g_h=1;
  52.     }
  53. }
  54.  
  55. void GEMchangearea::Include(const GRect& area)
  56. {
  57.     if (area.g_w>0 && area.g_h>0) {
  58.         Include(area.g_x,area.g_y);
  59.         Include(area.g_x+area.g_w-1,area.g_y+area.g_h-1);
  60.     }
  61. }
  62.